var commonUtil = require("../../../utils/commonUtil.js")
var globalData = getApp().globalData;
var httpsUrl = globalData.httpsUrl;
var imgUrl = globalData.imgUrl;
Page({

  data: {
    imgUrl: imgUrl,
    info:[],
  },
  save:function(e){
    var frm = e.detail.value;
    console.log("frm：" + JSON.stringify(frm));
    var info = this.data.info;
    info.extInfoValues = frm;
    console.log("info:" + JSON.stringify(info));
    wx.showLoading({ title: '请稍等...' })
    let openId = wx.getStorageSync("openidKey");
    wx.request({
      header: { "openId": openId, },
      url: httpsUrl + "/car/info",
      dataType: "json",
      method: "POST",
      data: info,
      success: function (res) {
        wx.hideLoading();
        res = res.data;
        console.log("返回：" + JSON.stringify(res));
        if (res.code == 0) {
          wx.navigateBack({
            delta: 1
          })
        } else {
          commonUtil.showModal(res.message);
        }
      }
    })
  },
  vehicleNo:function(e){
    //console.log(JSON.stringify(e));
    let val = e.detail.value;
    let info = this.data.info;
    info.vehicleNo = val;
    this.setData({info:info})
  },
  models: function (e) {
    let val = e.detail.value;
    let info = this.data.info;
    info.models = val;
    this.setData({ info: info })
  },
  dispPowOutput: function (e) {
    let val = e.detail.value;
    let info = this.data.info;
    info.dispPowOutput = val;
    this.setData({ info: info })
  },
  drilicYear: function (e) {
    let val = e.detail.value;
    let info = this.data.info;
    info.drilicYear = val;
    this.setData({ info: info })
  },
  name: function (e) {
    let val = e.detail.value;
    let info = this.data.info;
    info.name = val;
    this.setData({ info: info })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let id = wx.getStorageSync("aidKey");
    var that = this;
    var params = new Object();
    params.aid = id;
    let openId = wx.getStorageSync("openidKey");
    wx.showLoading({ title: '请稍等...', })
    wx.request({
      header: { "openId": openId, "content-Type": "application/x-www-form-urlencoded" },
      url: httpsUrl + "/car/info",
      dataType: "json",
      method: "GET",
      data: params,
      success: function (res) {
        wx.hideLoading();
        res = res.data;
        console.log("car：" + JSON.stringify(res));
        if (res.code == 0) {
          that.setData({ info: res.data })
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})